﻿#include "cameraworker.h"
#include <QThread>
CameraWorker::CameraWorker(QObject *parent) : QObject(parent)
{

}

CameraWorker::~CameraWorker()
{
}
void CameraWorker::Initialize()
{
	m_bIsStreaming = false;
	m_control = new SBaslerCameraControl(this);
    m_control->initSome();
    connect(m_control, &SBaslerCameraControl::sigCurrentImage, this, &CameraWorker::OnFrameReady);

    m_control->OpenCamera(m_cData.qStrCameraID);
    //m_control->setFeatureTriggerSourceType("Line1");
    //m_control->getFeatureTriggerSourceType();
}

void CameraWorker::start()
{
    m_control->StartAcquire();
}

void CameraWorker::stop()
{
    m_control->StopAcquire();
}

void CameraWorker::OnFrameReady(QImage img){
    HalconCpp::HObject hImg;
    int width = img.width(), height = img.height();
    HalconCpp::GenImage1(&hImg, "byte", width, height, (Hlong)(img.bits()));
    m_cData.Hobj = hImg;
    emit sigAlgStart(m_cData);
}
